<%@ page language="java" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" %>
$(function(){
	
	var docId=$("#docId").val();//流程id,查询已有附件条件
	var controlId="fileUpload";//自定义控件名前缀
	var delFlag="1";//显示删除按钮：0，不显示；1，显示
	var addFlag="1";//添加按钮可用：0，不可用；1，可用
	var showControlFlag="1";//显示file控件和上传按钮：0，不显示；1，显示
	//var docType="";//流程状态：为done时候控制file控件和上传按钮不显示----issue.js已有
	
	var attachNo="0";//查询已有附件条件
	var attachVersion="0";//查询已有附件条件
	var attachType="AS";//查询已有附件条件
	
	$("#fileDiv").panel({
	    href:_synergyContext+'/basic/synAttach/gotoSynAttachPage?docId='
	    	+docId+'&controlId='+controlId+'&delFlag='+delFlag+'&addFlag='+addFlag
	    	+'&showControlFlag='+showControlFlag+'&docType='+_issueType
	    	+"&attachNo="+attachNo+"&attachVersion="+attachVersion
			   +"&attachType="+attachType,
	    border:false,//不显示边框
	    cache:false//不从缓存加载面板
	});
	
	addValid();
	
	$("#workEffortId").val(docIssue.workEffortId);
	
	//设置不可编辑
	if("<c:our value='editFlag'/>"!="1"){
		
	}
});

function saveDocIssueData(){
	if(!$("#docIssueForm").form('validate')){
		return;
	}
	
	$.ajax({
		   type: "POST",
		   url: "<c:url value='/docDispatch/save' />",
		   data: $('#docIssueForm').serialize(),
		   dataType: "json",
		   success: function(msg){
		     if(msg.state=="200"){
		    	 //docIssue数据显示到前台页面
		    	 $("#docId").val(msg.docIssue.docId);
		    	 showBaseData(msg.docIssue);
		    	 if(fileUploadSaveFileFt(msg.docIssue.docId,"0","0","AS","")){
		    		 //附件信息显示到前台页面
		    		 showFileData(msg.docIssue.docId);
		    		 //关闭窗口
		    		 closeDialog();
		    	 }else{
		    		 $.messager.alert("提示","保存附件失败"); 
		    	 }
		     }else{
		    	 $.messager.alert("提示","保存数据失败");
		     }
		   }
		});
}

//绑定验证
function addValid(){
	//标题
	$("#docName").textbox({
	    required: true,
	    validType:'length[1,100]'
	});
	
	//主送
	/*$("#zhusong").textbox({
	    required: true
	});*/
	
	//份数
	$("#printNum").numberbox({
	    required: true,
	    min:1,
	    precision:0
	});
	
	//是否公开
	$('#remark').combobox({
		editable:false, 
		required: true,
		validType: 'selectValueRequired'
	});
	
	//拟稿人电话
	$("#drafterTel").textbox({
	    required: true,
	    validType:'requireTelNum'
	});
}